using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdminApiTemplate.Common.Helpers
{
    /// <summary>
    /// 随机相关处理类
    /// </summary>
    public class RandomHelper
    {
        /// <summary>
        /// 单例
        /// </summary>
        public static readonly Random Instance = new Random();

        /// <summary>
        /// 生成请求Id
        /// </summary>
        /// <param name="maxLength"></param>
        /// <returns></returns>
        public static string RequestId(int maxLength = 6)
        {
            var sb = new StringBuilder();
            for (int i = 0; i < maxLength; i++)
            {
                sb.Append(Instance.Next(10));
            }
            return $"{DateTime.Now.ToString("yyyyMMddHHmmss")}{sb}";
        }
    }
}
